<?php
/**
 * @copyright   Copyright (C) Open Web Software Ltda. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Detecting Active Variables
$option   = $app->input->getCmd('option', '');
$view     = $app->input->getCmd('view', '');
$layout   = $app->input->getCmd('layout', '');
$task     = $app->input->getCmd('task', '');
$itemid   = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');
$activeLang = $this->language;

$bodyClass = "site";
$bodyClass .= ($option != "")     ? " " . $option : "";
$bodyClass .= ($view != "")       ? " view-" . $view : "";
$bodyClass .= ($layout != "")     ? " layout-" . $layout : "";
$bodyClass .= ($task != "")       ? " task-" . $task : "";
$bodyClass .= ($itemid != "")     ? " itemid-" . $itemid : "";
$bodyClass .= ($activeLang != "") ? " lang-" . $activeLang : "";

if (!class_exists('Mobile_Detect')) {
	include 'tools/Mobile_Detect.php';
}
$detect = new Mobile_Detect();

if ($detect->isMobile() && !$detect->isTablet()){
	include 'index.mobile.php';
}
else
{
// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');
include 'tools/Browser_Detect.php';
// Add Stylesheets

// Compilar LESS y usar en produccion
// $doc->addStyleSheet('templates/'.$this->template.'/css/template.css');

if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/templates/'.$this->template.'/css/browser-' . strtolower(browserDetect()) . '.css')){
	$doc->addStyleSheet('templates/'.$this->template.'/css/browser-' . strtolower(browserDetect()) . '.css');
}

// Load optional rtl Bootstrap css and Bootstrap bugfixes
JHtmlBootstrap::loadCss($includeMaincss = false, $this->direction);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <jdoc:include type="head" />
  <!-- adicion de css y js de less para usar durante el desarrollo -->
  <link rel="stylesheet/less" type="text/css" href="templates/<?php echo $this->template ?>/css/template.less" />
  <script src="templates/<?php echo $this->template ?>/js/less-1.3.3.min.js" type="text/javascript"></script>
</head>
<body class="<?php echo $bodyClass;?>">
	<!-- Body -->
	<div class="container">
		<jdoc:include type="modules" name="position-1" style="none" />
		<div class="row">
	    <div class="span3">
	      <!--Sidebar content-->
				<hr />
				<jdoc:include type="modules" name="position-5" style="none" />
				<hr />
				<jdoc:include type="modules" name="position-6" style="none" />
				<hr />
				<jdoc:include type="modules" name="position-7" style="none" />
				<hr />
				<jdoc:include type="modules" name="sitemapload" style="none" />
				<hr />
	    </div>
	    <div class="span9">
	      <!--Body content-->
	      <jdoc:include type="message" />
				<hr />
				<jdoc:include type="component" />
				<hr />
	    </div>
	  </div>
	</div>

	<jdoc:include type="modules" name="debug" style="none" />
</body>
</html>
<?php
}
?>